package com.yuanlrc.base.dao.common;

import com.yuanlrc.base.entity.common.GoodsCategory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 物品分类管理dao层
 */
@Repository
public interface GoodsCategoryDao extends JpaRepository<GoodsCategory,Long> {
    List<GoodsCategory> findByParentIsNull();

    /**
     * 获取所以二级分类
     * @return
     */
    List<GoodsCategory> findByParentIsNotNull();

    @Query("select gc from GoodsCategory gc where gc.id=:id")
    GoodsCategory find(@Param("id") Long id);
}
